//
//  MoveView.m
//  Mtime2.0
//
//  Created by 凉气的Mac on 16/9/8.
//  Copyright © 2016年 凉气的Mac. All rights reserved.
//

#import "MoveView.h"

@interface MoveView ()

@property(nonatomic,weak) UIImageView *lineImageView;

@end

@implementation MoveView



-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        //设置界面
        [self setupUI];
        
    }
    return self;
}

#pragma mark --
#pragma mark --设置界面
-(void)setupUI{
    
    [self addHeaderView];
    
    self.backgroundColor = [UIColor redColor];

    
    
    
}


#pragma mark --
#pragma mark --添加头部View
-(void)addHeaderView{

    UIView *headerView  = [[UIView alloc]init];
    
    headerView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1.000];
    
    [self addSubview:headerView];
    
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.trailing.leading.equalTo(self);
        
        make.height.equalTo(@44);
        
    }];
    
    NSArray *titleArray = @[@"正在热映",@"即将上映"];
    
    UIButton *tempBtn;
    
    for (int i = 0; i < titleArray.count; i++) {
        
        UIButton *button = [[UIButton alloc]init];
        
        [button setTitle:titleArray[i] forState:UIControlStateNormal];
        
        [button setTitleColor:[UIColor colorWithRed:0.020 green:0.402 blue:1.000 alpha:1.000] forState:UIControlStateNormal];
        
        [headerView addSubview:button];

        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.bottom.equalTo(headerView);
            
            make.width.equalTo(headerView).multipliedBy(0.5);
            
            make.leading.equalTo(tempBtn ? tempBtn.mas_trailing : headerView);
            
        }];
        
        tempBtn = button;
        
        [button addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    
    UIImageView *lineImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"menu_top_bg"]];
    
    self.lineImageView = lineImageView;
    
    [headerView addSubview:lineImageView];
    
    [lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.leading.bottom.equalTo(headerView);
        
        make.height.equalTo(@2);
        
        make.width.equalTo(headerView).multipliedBy(0.5);
        
    }];
    
    

}


-(void)clickBtn:(UIButton *)button{

    self.lineImageView.transform = CGAffineTransformMakeTranslation(button.x, 0);
    

}






@end








































































